
#ifndef INVENTORY_H_
#define INVENTORY_H_

#include "RenderBlock.h"

int slots [27];

int clickedField(u16 x, u16 y) {
	for(int i = 0; i < 7; i++) {
		for(int j = 0; j < 3; j++) {
			if((x >= 10+20*i) && (y >= 10+20+20*j) &&
			   (x < 10+20*i+16) && (y < 10+20+20*j+16)) {
				return i+j*7;
			}
		}
	}
	return -1;
}

void drawInventory() {
	for(int i = 0; i < 7; i++) {
		for(int j = 0; j < 3; j++) {
			Block* block = getBlockWith(slots[i+j*7]);
			if(block != 0) {
				int j1 = block->getTextureFrom(0);
				draw2DQuad(oamSub, 1+(i+j*7), 10+20*i, 10+20+20*j, j1%16, j1/16);
			}
		}
	}
}

void fillInventory() {
	for(int i = 0; i < 27; i++) {
		Block* block = getBlockWith(i+1);
		if(block != 0) {
			slots[i] = block->blockID;
		} else {
			slots[i] = 0;
		}
	}
}

#endif /* INVENTORY_H_ */
